package com.efounder.message.struct;

import android.util.Log;

import java.nio.ByteBuffer;


public class IMStruct001 extends IMStructAdpter
{
	private String clientId = null;
	private String lastMessageTime = null;

	public String getClientId()
	{
		return clientId;
	}


	public void setClientId(String clientId)
	{
		this.clientId = clientId;
	}

	public String getLastMessageTime() {
		return lastMessageTime;
	}

	public void setLastMessageTime(String lastMessageTime) {
		this.lastMessageTime = lastMessageTime;
	}


	public byte getMessageType()
	{
		return (byte)1;
	}



	public byte[] toByteArray()
	{
		String token_time = clientId;
		if(lastMessageTime != null){
			//把token和lastTime拼一起
			token_time = token_time + "&lastMsgTime=" +lastMessageTime;
		}
		Log.i("IMStruct001--token_time", token_time);
		byte[] clientIdBytes = token_time.getBytes();

		byte[] byteArray = new byte[1+4+clientIdBytes.length];
		ByteBuffer buffer = ByteBuffer.wrap(byteArray);

		buffer.put(this.getMessageType());
		buffer.putInt(clientIdBytes.length);
		buffer.put(clientIdBytes);

		return byteArray;

	}
	public String toString()
	{
		return this.clientId;
	}

	public IMStruct copy()
	{
		IMStruct001 struct = new IMStruct001();
		struct.setClientId(clientId);
		return struct;
	}
}
